/**
 * @(#)RecordMappingFailureException.java             Oct 4, 2009 8:49:04 PM
 */
package com.radeonsys.litmus.data;

import org.springframework.core.NestedRuntimeException;

/**
 * Thrown when there was an error mapping an instance of {@link Record} to an object
 *
 * @author Ranganath Kini (ranganathkini at gmail dot com)
 * @version 1.0
 */
public class RecordMappingFailureException extends NestedRuntimeException {

    /**
	 * The generated serial version UID for this class
	 */
	private static final long serialVersionUID = 3440768900067612385L;
	
	// stores a reference to the record which could not be mapped
    private final Record _record;

    /**
     * Creates a new instance of <code>RecordMappingFailureException</code> with the specified error message
     * 
     * @param errorMessage  an error message describing the reason for this error
     * @param record        a reference to the {@link Record} instance which could not be mapped.
     */
    public RecordMappingFailureException(final String errorMessage, final Record record) {
        super(errorMessage);
        _record = record;
    }

    /**
     * Creates a new instance of <code>RecordMappingFailureException</code> with the specified error message and
     * specified underlying cause of this error
     * 
     * @param errorMessage  an error message describing the reason for this error
     * @param cause         reference to an instance of {@link Throwable} representing the underlying cause of this
     *                      error
     * @param record        a reference to the {@link Record} instance which could not be mapped.
     */
    public RecordMappingFailureException(final String errorMessage, final Throwable cause, final Record record) {
        super(errorMessage, cause);
        _record = record;
    }

    /**
     * Returns the record which could not be mapped.
     * 
     * @return  a reference to the {@link Record} instance which could not be mapped.
     */
    public Record getRecord() {
        return _record;
    }
}
